let queue = 3;
let list = [
    {
        name: 'file 1'
    },
    {
        name: 'file 2'
    },
    {
        name: 'file 3'
    },
    {
        name: 'file 4'
    },
    {
        name: 'file 5'
    },
    {
        name: 'file 6'
    },
    {
        name: 'file 7'
    },
]

function upload(item) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            console.log('success>>', item.name)
            resolve();
        }, 3000)
    })
}

function loop(item) {
    console.info("uploading>>", item.name)
    upload(item).then(() => {
        let index = list.findIndex(item => !item.uploaded)
        if (index > -1) {
            list[index].uploaded = true;
            loop(list[index]);
        }
    }).catch(err => {

    })
}

function begin() {
    for (let i = 0; i < queue; i++) {
        list[i].uploaded = true;
        loop(list[i])
    }
}

begin()